package com.ftg.learn.product.controller;

import com.ftg.learn.product.pojo.Dept;
import com.ftg.learn.product.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    DeptService deptService;

    @GetMapping("/show")
    public List<Dept> show() {
        return deptService.show();
    }


    @PutMapping("/findone/{deptno}")
    public List<Dept> findone(@PathVariable("deptno") String deptno) {
        return deptService.findone(deptno);
    }

    @PostMapping("/update")
    public int update(@RequestBody Dept dept) {
        return deptService.update(dept);
    }

    @DeleteMapping("/delete/{deptno}")
    public int delete(@PathVariable("deptno") String deptno) {
        return deptService.delete(deptno);
    }

    @PostMapping("/save")
    public int save(@RequestBody Dept dept) {
        return deptService.save(dept);
    }
}